# Maintainer: Daurnimator <daurnimator@archlinux.org>
# Maintainer: Laurent Carlier <lordheavym@gmail.com>

pkgname=spirv-tools
pkgver=2023.5
# There was no release tag, just the release candidate
_tag="${pkgver}.rc1"
pkgrel=1
pkgdesc="API and commands for processing SPIR-V modules"
arch=('loong64' 'x86_64')
url="https://www.khronos.org/vulkan/"
license=('custom')
groups=(vulkan-devel)
depends=('gcc-libs' 'sh')
makedepends=('cmake' 'python' 'ninja' 'spirv-headers')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/${_tag}.tar.gz")
sha256sums=('aed90b51ce884ce3ac267acec75e785ee743a1e1fd294c25be33b49c5804d77c')

build() {
  cd "SPIRV-Tools-${_tag}"

  cmake \
      -Bbuild \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DCMAKE_BUILD_TYPE=None \
      -DSPIRV_WERROR=Off \
      -DBUILD_SHARED_LIBS=ON \
      -DSPIRV_TOOLS_BUILD_STATIC=OFF \
      -DSPIRV-Headers_SOURCE_DIR=/usr
  ninja -C build
}

check() {
  cd "SPIRV-Tools-${_tag}"
  ninja -C build test
}

package() {
  cd "SPIRV-Tools-${_tag}"

  DESTDIR="${pkgdir}" ninja -C build install

  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
